<%@ page language="java" contentType="text/html;" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc.jsp"></jsp:include>
<style type="text/css">
.list_wrap{
    list-style: none;
    margin-top: 10px;
    padding-left: 10px;
}
.list_wrap li{
    padding: 8px;
}
.table_b{
    border: 1px dotted #ddd;
    margin-bottom:5px;
    margin-top:-10px;
    margin-left:20px;
    border-left:1px dotted #95b8e7;
    border-top:1px dotted #95b8e7;
}
.table_b thead{
     color:#3989c8;
}
.table_b td{
	border:1px dotted #ddd;
	padding:5px;
	text-align: center;
}
.orderdetail_header{
	padding:10px;
	background-color: #ffffff;
	color:#3989c8;
	font-weight: bold;
	font-size: 14px;
	border:1px solid #95B8E7;
}
</style>
</head>
<body>
	<div class="orderdetail_header">
		平台订单号：<span id="orderNumber">${orderNumber}</span>&nbsp;&nbsp;&nbsp;&nbsp;
		PSS订单号：<span id="pssOrderNumber"></span>&nbsp;&nbsp;&nbsp;&nbsp;
		业务状态：<span id="bizStatus"></span>&nbsp;&nbsp;&nbsp;&nbsp;
		财务状态：<span id="payStatus"></span>
	</div>
	<div class="easyui-layout" data-options="fit:true"  style="overflow:auto;">
			<div class="easyui-panel" title="产品信息">
				<ul class="list_wrap">
					<li>航线： <span id="itineraryName"></span></li>
					<li>往返间隔天数：<span id="periodDesc"></span></li>
					<li>航班信息：</li>
				</ul>
				<table cellpadding="0" cellspacing="0" width="90%" class="table_b" id="tbl_flights">
					<thead>
					<tr>
						<td width="5%">序号</td>
						<td width="10%">航班号</td>
						<td width="10%">舱位</td>
						<td width="45%">行程</td>
						<td width="10%">起飞日期</td>
						<td width="10%">出发时刻</td>
						<td>到达时刻</td>
					</tr>
					</thead>
				</table>
			</div>
			<div class="easyui-panel" title="旅客信息" style="height:auto;">
				<ul class="list_wrap">
					<li>确认旅客人数： <span id="passengerSummaryInfo"></span></li>
					<li>确认旅客名单：</li>
				</ul>
				<table cellpadding="0" cellspacing="0" width="90%" class="table_b" id="tbl_passengers">
					<thead>
					<tr>
						<td width="5%">序号</td>
						<td width="10%">票号</td>
						<td width="10%">旅客姓名</td>
						<td width="10%">中文姓名</td>
						<td width="5%">性别</td>
						<td width="10%">旅客类型</td>
						<td width="10%">证件类型</td>
						<td width="10%">证件号</td>
						<td width="10%">证件有效期</td>
						<td width="10%">出生日期</td>
						<td>手机号</td>
					</tr>
					</thead>
				</table>
			</div>

			<div class="easyui-panel" title="价格及支付" >
				<ul class="list_wrap">
					<li>票价： &nbsp;&nbsp;<span id="price"></span>&nbsp;&nbsp;元/人 &nbsp;&nbsp;&nbsp;&nbsp;采购数量：<span id="bookingCount"></span></li>
					<li>支付信息：</li>
				</ul>
				<table cellpadding="0" cellspacing="0" width="75%" class="table_b" id="tbl_payment">
					<thead>
					<tr>
						<td width="20%">支付金额</td>
						<td width="30%">支付截止时间</td>
						<td width="20%">类型</td>
						<td width="30%">状态</td>
					</tr>
					</thead>
				</table>
			</div>
			<br><br><br><br>
	</div>

<script type="text/javascript">
function initPage(b){
	if(b==null){
		layer.alert("订单【${orderNumber}】不存在!");
		closeCurrentWindow();
		return;
	}
	$("#orderNumber").text(b.orderNumber);
	$("#pssOrderNumber").text(b.pssOrderNumber);
	$("#bizStatus").text(CommonConverter.toOrderBizStatusStr(b.orderStatus));
	$("#payStatus").text(CommonConverter.toOrderPayStatusStr(b.financeStatus));

	// var jPopWindowTitleDiv = $(".layui-layer-title",window.parent.document);
	// jPopWindowTitleDiv.html("查看详情  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
	// 	+ "平台订单号：${orderNumber} &nbsp;&nbsp;&nbsp;&nbsp;"
	// 	+ "PSS订单号："+b.pssOrderNumber+"&nbsp;&nbsp;&nbsp;&nbsp;"
	// 	+ "业务状态："+CommonConverter.toOrderBizStatusStr(b.orderStatus)+"&nbsp;&nbsp;&nbsp;&nbsp;"
	// 	+ "财务状态："+CommonConverter.toOrderPayStatusStr(b.financeStatus) );

	$("#itineraryName").text(b.toStartAirport+"-"+b.toEndAirport+"（"+b.toStartAirportCode+"-"+b.toEndAirportCode+"）");
	$("#periodDesc").text(b.travelDays);
	$("#bookingCount").text(b.purchQuantity);
	$("#price").text(b.unitPrice);
	for(var i in b.flights){
		var f = b.flights[i];
		$("#tbl_flights").append("<tr class='table_body'>"
			+"<td>"+f.flightSegment+"</td>"
			+"<td>"+f.flightNumber+"</td>"
			+"<td>"+CommonConverter.toFlightCabinTypeStr(f.cabin)+"</td>"
			+"<td>"+f.departureCity+"（"+f.departureCode+"）"+f.departureTerminal+"-"+f.arrivalCity+"（"+f.arrivalCode+"）"+f.arrivalTerminal+"</td>"
			+"<td>"+f.departureDateStr+"</td>"
			+"<td>"+CommonConverter.formatFlightTime(f.departureTime)+"</td>"
			+"<td>"+CommonConverter.formatFlightTime(f.arrivalTime) + (f.intervalDay>0?("(+"+f.intervalDay+")"):"")+"</td>"
			+"</tr>");
	}

	var qAdult=0, qChildren=0,qInfant=0;
	for(var j=0;j<b.passengers.length;j++){
		var p = b.passengers[j];
		if(p.passageType==2){qChildren++;}
		if(p.passageType==1){qAdult++;}
		if(p.passageType==3){qInfant++;}
		$("#tbl_passengers").append("<tr class='table_body'>"
			+"<td>"+(j+1)+"</td>"
			+"<td>"+p.ticketNumber+"</td>"
			+"<td>"+p.firstName_en+"&nbsp;"+p.lastName_en+"</td>"
			+"<td>"+p.lastName_cn+p.firstName_cn+"</td>"
			+"<td>"+CommonConverter.toPassengerSexStr(p.sex)+"</td>"
			+"<td>"+CommonConverter.toPassengerTypeStr(p.passageType)+"</td>"
			+"<td>"+CommonConverter.toPassengerDocTypeStr(p.docType)+"</td>"
			+"<td>"+p.docId+"</td>"
			+"<td>"+p.docExpireDate+"</td>"
			+"<td>"+p.birthDate+"</td>"
			+"<td>"+p.mobile+"</td>"
			+"</tr>");
	}
	//$("#tbl_passengers").append("<tr class='table_body'><td colspan='11' style='text-align:left;'>总计：成人"+b.passengers.length+"人</td></tr>");
	var passengerSummaryInfo = "";
	if(qAdult>0) {passengerSummaryInfo = passengerSummaryInfo + "&nbsp;&nbsp;成人" + qAdult +"人";}
	if(qChildren>0) {passengerSummaryInfo = passengerSummaryInfo + "&nbsp;&nbsp;儿童" + qChildren +"人";}
	if(qInfant>0) {passengerSummaryInfo = passengerSummaryInfo + "&nbsp;&nbsp;婴儿" + qInfant +"人";}
	if(passengerSummaryInfo==""){passengerSummaryInfo = "0人";};
	$("#passengerSummaryInfo").html(passengerSummaryInfo);

	$("#tbl_payment").append("<tr class='table_body'>"
		+"<td>"+CommonConverter.formatMoney(b.payPrice)+"</td>"
		+"<td>"+b.payEndTime+"</td>"
		+"<td>票款</td>"
		+"<td>"+CommonConverter.toOrderPayStatusStr(b.financeStatus)+"</td>"
		+"</tr>");

}

function closeCurrentWindow(){
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}

$(function(){

	$.ajax({
		type:'get',
		url:'${ctx}/nporder/orderDetail/${orderNumber}',
		contentType:'application/json;charset=utf-8',
		dataType:'json',
		async:false,
		success:function(data){
			if(data.success){
				initPage(data.obj);
				return;
			}
			else{
				layer.alert(data.msg);
				closeCurrentWindow();
			}
		},
		error:function(msg){
			layer.alert("请检查您的网络连接，然后重试！");
			closeCurrentWindow();
		}
	}); 

});
</script>

</body>
</html>